from collections import defaultdict


def default_factory():
    return defaultdict(default_factory)


d = defaultdict(default_factory, foo='bar')
print('d : ', d)
print('foo => ', d['foo'])
print('bar => ', d['bar'])
t = d['bar']
tt = t['foo']
print(tt)


